/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.cqcis.uip.base.framework.common;


/**
 * task状态描述
 * 
 * @author huangmy
 * @date   2008-1-26
 */
public enum State {
	WAITRELA(-3),          /*等待关联结束*/
	INVALID(-2),          /*无效*/
	ERROR(-1),          /*处理失败*/
	WAIT(0),            /*未处理*/
	SUCCESS(1),         /*处理成功*/	
	DEALING(2);         /*正处理*/
				
	private int state;
	private String name;
	
	State(int state) {
		this.state = state;
		
		switch(state) {
		case  0:
			this.name = "WAIT";
			return;
		case  1:
			this.name = "SUCCESS";	
			return;
		case -1:
			this.name = "ERROR";
			return;				
		case  2:
			this.name = "DEALING";
			return;	
		case  -2:
			this.name = "INVALID";
			return;
		case  -3:
			this.name = "WAITRELA";
			return;
		}			 
	}
	
	public int getState() {
		return state;
	}
	
	public static State parse(int state) {
		switch(state) {
		case  0:
			return WAIT;
		case  1:
			return SUCCESS;
		case -1:
			return ERROR;
		case  2:
			return DEALING;	
		case  -2:
			return INVALID;	
		case  -3:
			return WAITRELA;	
		}
		
		return null;
	}
	
	@Override
	public String toString() {			
		return this.name;
	}
}
